package Singleto;
//饿汉式
public class Singleto1 {
    //保证类首先加载 并且只实例化一个  饿汉式
    private static final Singleto1 INSTANCE = new Singleto1();

    //私有化构造器
    private Singleto1(){}

    //创建完成后只有getInstance这一种方式去调用
    public static Singleto1 getInstance() {return INSTANCE;}

    public void m(){
        System.out.println("m");
    }

    public static void main(String[] args) {
        Singleto1 s1 =Singleto1.getInstance();
        Singleto1 s2 = Singleto1.getInstance();
        System.out.println(s1==s2);
    }
}
